[JavaScript] How to get the uri of the .js file itself.
Posted
by Vikrant Chaudhary
on Stack Overflow
See other posts from Stack Overflow
or by Vikrant Chaudhary
Published on 2010-06-03T14:38:57Z
Indexed on
2010/06/03
14:44 UTC
Read the original article
Hit count: 349
JavaScript
Hi, is there a method in JavaScript by which I can find out the path/uri of the executing script.
For example:
index.htmlincludes a JavaScript filestuff.jsand sincestuff.jsfile depends on./commons.js, it wants to include it too in the page. Problem is thatstuff.jsonly knows the relative path of./commons.jsfrom itself and has no clue of full url/path.index.htmlincludesstuff.jsfile as<script src="http://example.net/js/stuff.js?key=value" />andstuff.jsfile wants to read the value ofkey. How to?
© Stack Overflow or respective owner